package com.onenine.app.view.dialog;

import android.content.Context;
import android.support.v7.app.AppCompatDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.onenine.app.R;
import com.onenine.app.activity.LoginActivity;
import com.onenine.app.utils.RoleResLoader;
import com.onenine.common.util.ActivityUtils;

/**
 * 登录失效，重新登录
 */
public class QuitLoginDialog extends AppCompatDialog implements View.OnClickListener {

    public QuitLoginDialog(Context context, String message) {
        super(context, R.style.DialogStyle);
        setCancelable(false);
        setCanceledOnTouchOutside(false);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.layout_quit_login_dialog, null);
        setContentView(view);
        TextView tvContent = view.findViewById(R.id.tv_content);
        tvContent.setText(message);
        Button btnReLogin = view.findViewById(R.id.btn_login_again);
        btnReLogin.setTextColor(RoleResLoader.getRoleColorResourceId(RoleResLoader.DynamicResName.THEME_COLOR));
        btnReLogin.setBackgroundResource(RoleResLoader
                .getRoleDrawableResourceId(RoleResLoader.DynamicResName.THEME_STROKE_WHITE_CORNER));
        btnReLogin.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.btn_login_again) {
            dismiss();
            ActivityUtils.finishAllActivities(true);
            ActivityUtils.startActivity(LoginActivity.class);
        }
    }

}
